// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed partial class DataframeAnalysisFeatureProcessorNGramEncoding : IDataframeAnalysisFeatureProcessorVariant
	{
		[JsonInclude]
		[JsonPropertyName("custom")]
		public bool? Custom { get; set; }

		[JsonInclude]
		[JsonPropertyName("feature_prefix")]
		public string? FeaturePrefix { get; set; }

		[JsonInclude]
		[JsonPropertyName("field")]
		public Elastic.Clients.Elasticsearch.Field Field { get; set; }

		[JsonInclude]
		[JsonPropertyName("length")]
		public int? Length { get; set; }

		[JsonInclude]
		[JsonPropertyName("n_grams")]
		public IEnumerable<int> NGrams { get; set; }

		[JsonInclude]
		[JsonPropertyName("start")]
		public int? Start { get; set; }
	}

	public sealed partial class DataframeAnalysisFeatureProcessorNGramEncodingDescriptor<TDocument> : SerializableDescriptorBase<DataframeAnalysisFeatureProcessorNGramEncodingDescriptor<TDocument>>
	{
		internal DataframeAnalysisFeatureProcessorNGramEncodingDescriptor(Action<DataframeAnalysisFeatureProcessorNGramEncodingDescriptor<TDocument>> configure) => configure.Invoke(this);
		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor() : base()
		{
		}

		private bool? CustomValue { get; set; }

		private string? FeaturePrefixValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }

		private int? LengthValue { get; set; }

		private IEnumerable<int> NGramsValue { get; set; }

		private int? StartValue { get; set; }

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor<TDocument> Custom(bool? custom = true)
		{
			CustomValue = custom;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor<TDocument> FeaturePrefix(string? featurePrefix)
		{
			FeaturePrefixValue = featurePrefix;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor<TDocument> Field(Elastic.Clients.Elasticsearch.Field field)
		{
			FieldValue = field;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor<TDocument> Field<TValue>(Expression<Func<TDocument, TValue>> field)
		{
			FieldValue = field;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor<TDocument> Length(int? length)
		{
			LengthValue = length;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor<TDocument> NGrams(IEnumerable<int> nGrams)
		{
			NGramsValue = nGrams;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor<TDocument> Start(int? start)
		{
			StartValue = start;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (CustomValue.HasValue)
			{
				writer.WritePropertyName("custom");
				writer.WriteBooleanValue(CustomValue.Value);
			}

			if (!string.IsNullOrEmpty(FeaturePrefixValue))
			{
				writer.WritePropertyName("feature_prefix");
				writer.WriteStringValue(FeaturePrefixValue);
			}

			writer.WritePropertyName("field");
			JsonSerializer.Serialize(writer, FieldValue, options);
			if (LengthValue.HasValue)
			{
				writer.WritePropertyName("length");
				writer.WriteNumberValue(LengthValue.Value);
			}

			writer.WritePropertyName("n_grams");
			JsonSerializer.Serialize(writer, NGramsValue, options);
			if (StartValue.HasValue)
			{
				writer.WritePropertyName("start");
				writer.WriteNumberValue(StartValue.Value);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class DataframeAnalysisFeatureProcessorNGramEncodingDescriptor : SerializableDescriptorBase<DataframeAnalysisFeatureProcessorNGramEncodingDescriptor>
	{
		internal DataframeAnalysisFeatureProcessorNGramEncodingDescriptor(Action<DataframeAnalysisFeatureProcessorNGramEncodingDescriptor> configure) => configure.Invoke(this);
		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor() : base()
		{
		}

		private bool? CustomValue { get; set; }

		private string? FeaturePrefixValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }

		private int? LengthValue { get; set; }

		private IEnumerable<int> NGramsValue { get; set; }

		private int? StartValue { get; set; }

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor Custom(bool? custom = true)
		{
			CustomValue = custom;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor FeaturePrefix(string? featurePrefix)
		{
			FeaturePrefixValue = featurePrefix;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor Field(Elastic.Clients.Elasticsearch.Field field)
		{
			FieldValue = field;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor Field<TDocument, TValue>(Expression<Func<TDocument, TValue>> field)
		{
			FieldValue = field;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor Field<TDocument>(Expression<Func<TDocument, object>> field)
		{
			FieldValue = field;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor Length(int? length)
		{
			LengthValue = length;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor NGrams(IEnumerable<int> nGrams)
		{
			NGramsValue = nGrams;
			return Self;
		}

		public DataframeAnalysisFeatureProcessorNGramEncodingDescriptor Start(int? start)
		{
			StartValue = start;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (CustomValue.HasValue)
			{
				writer.WritePropertyName("custom");
				writer.WriteBooleanValue(CustomValue.Value);
			}

			if (!string.IsNullOrEmpty(FeaturePrefixValue))
			{
				writer.WritePropertyName("feature_prefix");
				writer.WriteStringValue(FeaturePrefixValue);
			}

			writer.WritePropertyName("field");
			JsonSerializer.Serialize(writer, FieldValue, options);
			if (LengthValue.HasValue)
			{
				writer.WritePropertyName("length");
				writer.WriteNumberValue(LengthValue.Value);
			}

			writer.WritePropertyName("n_grams");
			JsonSerializer.Serialize(writer, NGramsValue, options);
			if (StartValue.HasValue)
			{
				writer.WritePropertyName("start");
				writer.WriteNumberValue(StartValue.Value);
			}

			writer.WriteEndObject();
		}
	}
}